package com.eastfair.auth.config.datasource;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.eastfair.database.datasource.BaseMybatisConfiguration;
import com.eastfair.database.datasource.LampMetaObjectHandler;
import com.eastfair.database.properties.DatabaseProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 配置一些 Mybatis 常用重用拦截器
 *
 * @author ligang
 * @date 2017-11-18 0:34
 */
@Configuration
@Slf4j
@EnableConfigurationProperties({DatabaseProperties.class})
public class ActivitiMybatisAutoConfiguration extends BaseMybatisConfiguration {
    public ActivitiMybatisAutoConfiguration(DatabaseProperties databaseProperties) {
        super(databaseProperties);
    }


    /**
     * Mybatis Plus 注入器
     *
     * @return 注入器
     */
    @Bean("myMetaObjectHandler")
    @ConditionalOnMissingBean
    public MetaObjectHandler getMyMetaObjectHandler() {
        return new LampMetaObjectHandler();
    }


}
